<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <style>
        .box {
            width: 300px;
            height: 200px;

            /* 写参照物，只能是祖先元素 */
            position: relative;
        }

        .box img {
            width: 300px;
            height: 200px;
        }

        .box p {
            width: 300px;
            height: 30px;
            line-height: 30px;
            text-align: center;

            /* alpha 透明度 */
            background-color: rgba(0, 0, 0, 0.5);
            color: #f00;

            /* 使用了绝对定位以后，需要给参照物 */
            position: absolute;
            top: 0;


            /* 隐藏p */
            height: 0;
            overflow: hidden;

            transition: 1s;

        }

        .box:hover p {
            height: 30px;
        }
    </style>
</head>

<body>

    <!-- 
        绝对定位：一个盒子飘在另一个盒子上面  
     -->


    <div class="box">
        <img src="https://imgcps.jd.com/ling4/100032670738/5Lqs6YCJ5aW96LSn/5L2g5YC85b6X5oul5pyJ/p-5bd8253082acdd181d02fa2e/2b21b49d/cr/s/q.jpg"
            alt="">
        <p>少时诵诗书所所所所所所所所</p>
    </div>


    <!-- 
        nth-child 
        nth-of-type 


        transition 
        transform:
        box-shadow 

        固定定位
    -->




</body>

</html>